/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package goodenglish.domain.model.lexicon;

import goodenglish.domain.model.LazyList;
import goodenglish.domain.model.studyplan.StudyPlanRepository;
import goodenglish.domain.service.StudyWordSelect;
import goodenglish.domain.service.impl.StudyWordOrderSelect;
import goodenglish.infrastructure.repository.db.StudyPlanRepositoryDb;
import goodenglish.interfaces.BeanFactory;

import java.util.List;

/**
 * 学习计划
 * 
 * @author 关攀攀 panpan_001@126.com
 */
public class StudyPlan {
	private String id;
	private List<StudyInfo> studyInfos;
	private String name;

	public void setId(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public List<StudyInfo> getStudyInfos() {
		if (this.studyInfos instanceof LazyList) {
			studyPlanRepository.loadStudyInfos(this);
		}
		return studyInfos;
	}

	public void setStudyInfos(List<StudyInfo> studyWords) {

		this.studyInfos = studyWords;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	/**
	 * 得到要学习的单词
	 * 
	 * @param preNewWord
	 * @return
	 */
	public StudyInfo getToStudyNewWord(StudyInfo preNewWord) {
		return studyWordSelect.next(this.getStudyInfos(), preNewWord);
	}

	private StudyWordSelect studyWordSelect = BeanFactory.getSingleInstance(StudyWordOrderSelect.class);
	private StudyPlanRepository studyPlanRepository = BeanFactory.getSingleInstance(StudyPlanRepositoryDb.class);
}
